<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('区域管理')"/>
    <th:block th:include="include :: layout-latest-css"/>
    <th:block th:include="include :: ztree-css"/>
    <th:block th:include="include :: datetimepicker-css"/>
</head>
<style>
    .search-collapse, .select-table {
        padding-top: 13px;
    }

    .select-list li p {
        margin: 7px 5px 5px 0px;
    }

    .select-list li {
        margin-top: 17px;
    }

    .table-striped .table > thead:first-child > tr:first-child > th {
        font-weight: normal;
        font-size: 13px;
        border: 1px solid #cccccc !important;
        border-right: 0px solid #cccccc !important;
    }

</style>
<body class="gray-bg">

<div class="ui-layout-west">
    <div class="box box-main">
        <div class="box-header">
            <div class="box-title">
                <i class="fa icon-grid"></i> 项目名称
            </div>
            <div class="box-tools pull-right">
                <a type="button" class="btn btn-box-tool" href="#" onclick="project()" title="管理项目"><i
                        class="fa fa-edit"></i></a>
                <button type="button" class="btn btn-box-tool" id="btnExpand" title="展开" style="display:none;"><i
                        class="fa fa-chevron-up"></i></button>
                <button type="button" class="btn btn-box-tool" id="btnCollapse" title="折叠"><i
                        class="fa fa-chevron-down"></i></button>
                <button type="button" class="btn btn-box-tool" id="btnRefresh" title="刷新项目"><i
                        class="fa fa-refresh"></i></button>
            </div>
        </div>
        <div class="ui-layout-content">
            <div id="tree" class="ztree"></div>
        </div>
    </div>
</div>


<div class="ui-layout-center">
    <div class="container-div">

        <div class="row">
            <div class="col-sm-12 search-collapse">
                <div class="tabs-container">
                    <!--选项卡-->
                    <ul class="nav nav-tabs">
                        <li class="active"><a data-toggle="tab" href="#tab-0" aria-expanded="true">基本</a></li>
                        <li class=""><a data-toggle="tab" href="#tab-1" aria-expanded="false">计划</a></li>
                        <li class=""><a data-toggle="tab" href="#tab-2" aria-expanded="false">完成</a></li>
                    </ul>

                    <!--内容区-->
                    <div class="tab-content">
                        <!--基本产值-->
                        <div id="tab-0" class="tab-pane active">

                            <!--筛选条件-->
                            <div class="col-sm-12 search-collapse search">
                                <form id="region-price">
                                    <input type="hidden" name="companyId">
                                    <input type="hidden" name="proId">
                                    <input type="hidden" name="programId">
                                    <div class="select-list">
                                        <ul>
                                            <li>
                                                <p>项目名称：</p>
                                                <div class="col-lg-2">
                                                    <input type="text" class="form-control" name="programName"/>
                                                </div>
                                            </li>
                                            <li>
                                                <p>产值口径：</p>
                                                <div class="col-lg-2">
                                                    <select name="outputCaliber"
                                                            class="form-control noselect2">
                                                        <option value="">请选择</option>
                                                        <option value="0">存</option>
                                                        <option value="1">增1</option>
                                                        <option value="2">增2</option>
                                                        <option value="3">增3</option>
                                                        <option value="4">增4</option>
                                                    </select>
                                                </div>
                                            </li>
                                            <li>
                                                <p>状态：</p>
                                                <div class="col-lg-2">
                                                    <select name="status"
                                                            class="form-control noselect2">
                                                        <option value="">请选择</option>
                                                        <option value="0">已竣已结</option>
                                                        <option value="1">已竣未结</option>
                                                        <option value="2">竣工准备</option>
                                                        <option value="3">在建</option>
                                                        <option value="4">待建</option>
                                                    </select>
                                                </div>
                                            </li>
                                            <li>
                                                <p>模式：</p>
                                                <div class="col-lg-2">
                                                    <select name="pattern" class="form-control noselect2">
                                                        <option value="">请选择</option>
                                                        <option value="0">对内</option>
                                                        <option value="1">对外</option>
                                                    </select>
                                                </div>
                                            </li>
                                            <div style="float: right;">
                                                <a class="btn btn-primary btn-rounded btn-sm"
                                                   onclick="$.table.search('region-price', 'bootstrap-price')"><i
                                                        class="fa fa-search"></i>&nbsp;搜索</a>
                                                <div style="height: 5px;"></div>
                                                <a class="btn btn-warning btn-rounded btn-sm"
                                                   onclick="$.form.reset('region-price', 'bootstrap-price')"><i
                                                        class="fa fa-refresh"></i>&nbsp;重置</a>
                                            </div>
                                        </ul>
                                    </div>
                                </form>
                            </div>
                            <div class="btn-group-sm" id="toolbar0" role="group">
                                <a class="btn btn-success add"
                                   onclick="add($('input[name=companyId]').val(),$('input[name=proId]').val(),'基本产值')">
                                    <i class="fa fa-plus"></i> 新增
                                </a>
                                <a class="btn btn-primary price add"
                                   onclick="edit($('input[name=proId]').val(),'基本产值')">
                                    <i class="fa fa-edit"></i> 修改
                                </a>
                                <a class="btn btn-danger price add" onclick="remove('基本产值')">
                                    <i class="fa fa-remove"></i> 删除
                                </a>
                                <a class="btn btn-warning export" onclick="exportStatisticExcel('基本产值')">
                                    <i class="fa fa-download"></i> 导出
                                </a>
                            </div>
                            <!--表格区-->
                            <div class="col-sm-12 select-table table-striped">
                                <table id="bootstrap-price"></table>
                            </div>
                        </div>
                        <!--计划预算-->
                        <div id="tab-1" class="tab-pane">
                            <div class="col-sm-12 search-collapse search">
                                <form id="region-budget">
                                    <input type="hidden" name="companyId">
                                    <input type="hidden" name="proId">
                                    <input type="hidden" name="programId">
                                    <div class="select-list">
                                        <ul>
                                            <li>
                                                <p>项目名称：</p>
                                                <div class="col-lg-2">
                                                    <input type="text" class="form-control" name="programName"/>
                                                </div>
                                            </li>
                                            <li>
                                                <p>产值口径：</p>
                                                <div class="col-lg-2">
                                                    <select name="outputCaliber"
                                                            class="form-control noselect2">
                                                        <option value="">请选择</option>
                                                        <option value="0">存</option>
                                                        <option value="1">增1</option>
                                                        <option value="2">增2</option>
                                                        <option value="3">增3</option>
                                                        <option value="4">增4</option>
                                                    </select>
                                                </div>
                                            </li>
                                            <li>
                                                <p>状态：</p>
                                                <div class="col-lg-2">
                                                    <select name="status"
                                                            class="form-control noselect2">
                                                        <option value="">请选择</option>
                                                        <option value="0">已竣已结</option>
                                                        <option value="1">已竣未结</option>
                                                        <option value="2">竣工准备</option>
                                                        <option value="3">在建</option>
                                                        <option value="4">待建</option>
                                                    </select>
                                                </div>
                                            </li>
                                            <li>
                                                <p>模式：</p>
                                                <div class="col-lg-2">
                                                    <select name="pattern" class="form-control noselect2">
                                                        <option value="">请选择</option>
                                                        <option value="0">对内</option>
                                                        <option value="1">对外</option>
                                                    </select>
                                                </div>
                                            </li>
                                            <div style="float: right;">
                                                <a class="btn btn-primary btn-rounded btn-sm"
                                                   onclick="$.table.search('region-budget', 'bootstrap-budget')"><i
                                                        class="fa fa-search"></i>&nbsp;搜索</a>
                                                <div style="height: 5px;"></div>
                                                <a class="btn btn-warning btn-rounded btn-sm"
                                                   onclick="$.form.reset('region-budget', 'bootstrap-budget')"><i
                                                        class="fa fa-refresh"></i>&nbsp;重置</a>
                                            </div>
                                        </ul>
                                    </div>
                                </form>
                            </div>
                            <div class="btn-group-sm" id="toolbar" role="group">
                                <a class="btn btn-success add"
                                   onclick="add($('input[name=companyId]').val(),$('input[name=proId]').val(),'计划预算')">
                                    <i class="fa fa-plus"></i> 新增
                                </a>
                                <a class="btn btn-primary budget add"
                                   onclick="edit($('input[name=proId]').val(),'计划预算')">
                                    <i class="fa fa-edit"></i> 修改
                                </a>
                                <a class="btn btn-danger budget add" onclick="remove('计划预算')">
                                    <i class="fa fa-remove"></i> 删除
                                </a>
                                <a class="btn btn-warning export" onclick="exportStatisticExcel('计划预算')">
                                    <i class="fa fa-download"></i> 导出
                                </a>
                            </div>
                            <div class="col-sm-12 select-table table-striped">
                                <table id="bootstrap-budget"></table>
                            </div>
                        </div>
                        <!--季度摸底-->
                        <div id="tab-2" class="tab-pane">
                            <div class="col-sm-12 search-collapse search">
                                <form id="region-details">
                                    <input type="hidden" name="companyId">
                                    <input type="hidden" name="proId">
                                    <input type="hidden" name="programId">
                                    <div class="select-list">
                                        <ul>
                                            <li>
                                                <p>项目名称：</p>
                                                <div class="col-lg-2">
                                                    <input type="text" class="form-control" name="programName"/>
                                                </div>
                                            </li>
                                            <li>
                                                <p>产值口径：</p>
                                                <select name="outputCaliber"
                                                        class="form-control noselect2">
                                                    <option value="">请选择</option>
                                                    <option value="0">存</option>
                                                    <option value="1">增1</option>
                                                    <option value="2">增2</option>
                                                    <option value="3">增3</option>
                                                    <option value="4">增4</option>
                                                </select>
                                            </li>
                                            <li>
                                                <p>状态：</p>
                                                <select name="status"
                                                        class="form-control noselect2"
                                                        required>
                                                    <option value="">请选择</option>
                                                    <option value="0">已竣已结</option>
                                                    <option value="1">已竣未结</option>
                                                    <option value="2">竣工准备</option>
                                                    <option value="3">在建</option>
                                                    <option value="4">待建</option>
                                                </select>
                                            </li>
                                            <li>
                                                <p>模式：</p>
                                                <select name="pattern" class="form-control noselect2">
                                                    <option value="">请选择</option>
                                                    <option value="0">对内</option>
                                                    <option value="1">对外</option>
                                                </select>
                                            </li>
                                            <div style="float: right;">
                                                <a class="btn btn-primary btn-rounded btn-sm"
                                                   onclick="$.table.search('region-details', 'bootstrap-details')"><i
                                                        class="fa fa-search"></i>&nbsp;搜索</a>
                                                <div style="height: 5px;"></div>
                                                <a class="btn btn-warning btn-rounded btn-sm"
                                                   onclick="$.form.reset('region-details', 'bootstrap-details')"><i
                                                        class="fa fa-refresh"></i>&nbsp;重置</a>
                                            </div>
                                        </ul>
                                    </div>
                                </form>
                            </div>
                            <div class="btn-group-sm" id="toolbar1" role="group">
                                <a class="btn btn-success add"
                                   onclick="add($('input[name=companyId]').val(),$('input[name=proId]').val(),'季度摸底')">
                                    <i class="fa fa-plus"></i> 新增
                                </a>
                                <a class="btn btn-primary details add"
                                   onclick="edit($('input[name=proId]').val(),'季度摸底')">
                                    <i class="fa fa-edit"></i> 修改
                                </a>
                                <a class="btn btn-danger details add" onclick="remove('季度摸底')">
                                    <i class="fa fa-remove"></i> 删除
                                </a>
                                <a class="btn btn-warning export" onclick="exportStatisticExcel('季度摸底')">
                                    <i class="fa fa-download"></i> 导出
                                </a>
                            </div>
                            <div class="col-sm-12 select-table table-striped">
                                <table id="bootstrap-details"></table>
                            </div>
                        </div>

                    </div>

                </div>
            </div>

        </div>
    </div>
</div>

<th:block th:include="include :: footer"/>
<th:block th:include="include :: layout-latest-js"/>
<th:block th:include="include :: ztree-js"/>
<th:block th:include="include :: datetimepicker-js"/>
<th:block th:include="include :: bootstrap-suggest-js"/>
<th:block th:include="include :: bootstrap-typeahead-js"/>


<script th:inline="javascript">

    /* 模块前缀url */
    var prefix = ctx + "planbudget";


    /* 初始化:获取所有工程公司下的项目名称 */
    $.get(ctx + "concreteManage/collection", function (data) {
        $("#progName0").typeahead({
            source: data.value
        });

        $("#progName").typeahead({
            source: data.value
        });

        $("#progName1").typeahead({
            source: data.value
        });

        $("#progName2").typeahead({
            source: data.value
        });
    }, 'json');

    /* 初始化方法 */
    $(function () {
        var panehHidden = false;
        $(".add").hide();
        $(".export").show();
        if ($(this).width() < 769) {
            panehHidden = true;
        }
        $('body').layout({initClosed: panehHidden, west__size: 300});

        // 初始化列表
        queryTotalList();
        queryConcreteList();
        queryBrickList();

        // 初始化树组件
        queryProjectTree();

    });

    /* 初始化 基本产值 */
    function queryTotalList() {
        var options = {
            id: "bootstrap-price",
            toolbar: "toolbar0",
            uniqueId: "basicId",
            url: prefix + "/basicList",
            createUrl: prefix + "/add{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            importUrl: prefix + "/importData",
            importTemplateUrl: prefix + "/importTemplate",
            showSearch: false,
            showRefresh: false,
            showToggle: false,
            showColumns: false,
            pagination: false,
            modalName: "数据",
            columns: [
                {
                    field: 'companyName',
                    align: 'center',
                    title: '工程公司',
                    valign: "middle",
                },
                {
                    field: 'programName',
                    align: 'center',
                    title: '项目名称',
                    valign: "middle",
                },
                {
                    field: 'programCode',
                    align: 'center',
                    title: '项目编码',
                    valign: "middle",
                },
                {
                    field: 'projectManager',
                    align: 'center',
                    title: '项目经理',
                    valign: "middle",
                },
                {
                    field: 'outputCaliberName',
                    align: 'center',
                    title: '产值口径',
                    valign: "middle",
                },
                {
                    field: 'bidTime',
                    align: 'center',
                    title: '中标日期',
                    valign: "middle",
                },
                {
                    field: 'statusName',
                    align: 'center',
                    title: '状态',
                    valign: "middle",
                },
                {
                    field: 'patternName',
                    align: 'center',
                    title: '模式',
                    valign: "middle",
                },
                {
                    field: 'bidPrice',
                    align: 'center',
                    title: '中标价',
                    valign: "middle",
                },
                {
                    field: 'preSettlePrice',
                    align: 'center',
                    title: '预估结算价(万元)',
                    valign: "middle",
                },
                {
                    field: 'accFinishPrice',
                    align: 'center',
                    title: '累计已完成(万元)',
                    valign: "middle",
                },
                {
                    field: 'countOffset',
                    align: 'center',
                    title: '偏差(万元)',
                    valign: "middle",
                },
                {
                    field: 'planFinishTime',
                    align: 'center',
                    title: '计划结工时间',
                    valign: "middle",
                },
                {
                    field: 'actualStartTime',
                    align: 'center',
                    title: '实际开工时间',
                    valign: "middle",
                },
                {
                    field: 'schedule',
                    align: 'center',
                    title: '工期（天）',
                    valign: "middle",
                },

            ]
        };
        $.table.init(options);
    }

    /* 初始化 计划预算 */
    function queryConcreteList() {
        var options = {
            id: "bootstrap-budget",
            toolbar: "toolbar",
            uniqueId: "checkId",
            url: prefix + "/budgeList",
            createUrl: prefix + "/add{id}",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            importUrl: prefix + "/importData",
            importTemplateUrl: prefix + "/importTemplate",
            showSearch: false,
            showRefresh: false,
            showToggle: false,
            showColumns: false,
            pagination: false,
            modalName: "数据",
            onLoadSuccess: function (data) {
                var num = 0;
                var arrName = ['companyName', 'programName', 'prePrice','poorQuality']
                for (var i = 0; i < data.rows.length; i++) {
                    for (var j = 0; j < arrName.length; j++) {
                        $('#bootstrap-budget').bootstrapTable('mergeCells', {
                            index: num,
                            field: arrName[j],
                            colspan: 1,
                            rowspan: 3
                        });
                    }
                    num = num + 3;
                }
            },
            columns: [
                // {
                //     field: 'planId',
                //     align: 'center',
                //     title: '主键',
                //     valign: "middle",
                // },
                {
                    field: 'companyName',
                    align: 'center',
                    title: '工程公司',
                    valign: "middle",
                },
                {
                    field: 'programName',
                    align: 'center',
                    title: '项目名称',
                    valign: "middle",
                },
                {
                    field: 'prePrice',
                    align: 'center',
                    title: '前期产值(万元)',
                    valign: "middle",
                },
                {
                    field: 'type',
                    align: 'center',
                    title: '类型',
                    valign: "middle",
                    formatter: function (value, row, index) {
                        if (value == 0) {
                            return '全年预算'
                        }
                        if (value == 1) {
                            return '全年计划'
                        }
                        if (value == 2) {
                            return '滚动计划'
                        }
                    }
                },
                {
                    field: 'total',
                    align: 'center',
                    title: '总计(万元)',
                    valign: "middle",
                },
                {
                    field: 'janValue',
                    align: 'center',
                    title: '一月(万元)',
                    valign: "middle",
                },
                {
                    field: 'febValue',
                    align: 'center',
                    title: '二月(万元)',
                    valign: "middle",
                },
                {
                    field: 'marValue',
                    align: 'center',
                    title: '三月(万元)',
                    valign: "middle",
                },
                {
                    field: 'aprValue',
                    align: 'center',
                    title: '四月(万元)',
                    valign: "middle",
                },
                {
                    field: 'mayValue',
                    align: 'center',
                    title: '五月(万元)',
                    valign: "middle",
                },
                {
                    field: 'junValue',
                    align: 'center',
                    title: '六月(万元)',
                    valign: "middle",
                },
                {
                    field: 'julValue',
                    align: 'center',
                    title: '七月(万元)',
                    valign: "middle",
                },
                {
                    field: 'augValue',
                    align: 'center',
                    title: '八月(万元)',
                    valign: "middle",
                },
                {
                    field: 'sepValue',
                    align: 'center',
                    title: '九月(万元)',
                    valign: "middle",
                },
                {
                    field: 'octValue',
                    align: 'center',
                    title: '十月(万元)',
                    valign: "middle",
                },
                {
                    field: 'novValue',
                    align: 'center',
                    title: '十一月(万元)',
                    valign: "middle",
                },
                {
                    field: 'decValue',
                    align: 'center',
                    title: '十二月(万元)',
                    valign: "middle",
                },
                {
                    field: 'poorQuality',
                    align: 'center',
                    title: '材差及签证调整额(万元)',
                    valign: "middle",
                },
            ]
        };
        $.table.init(options);
    }

    /* 初始化 季度摸底 */
    function queryBrickList() {
        var options = {
            id: "bootstrap-details",
            toolbar: "toolbar1",
            uniqueId: "checkId",
            url: prefix + "/detailList",
            createUrl: prefix + "/add{id}",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/removeBrick",
            exportUrl: prefix + "/exportBrick",
            importUrl: prefix + "/importData",
            importTemplateUrl: prefix + "/importTemplate",
            showSearch: false,
            showRefresh: false,
            showToggle: false,
            showColumns: false,
            pagination: false,
            modalName: "数据",
            columns: [
                [
                    {
                        field: 'companyName',
                        align: 'center',
                        title: '工程公司',
                        valign: "middle",
                        rowspan: 2,
                    },
                    {
                        field: 'programName',
                        align: 'center',
                        title: '项目名称',
                        valign: "middle",
                        rowspan: 2,
                    },
                    {
                        field: 'firstForward',
                        align: 'center',
                        title: '一季度结转(万元)',
                        valign: "middle",
                        rowspan: 2,
                    },
                    {
                        align: 'center',
                        title: '二季度(万元)',
                        valign: "middle",
                        rowspan: 1,
                        colspan: 4
                    },
                    {
                        align: 'center',
                        title: '三季度(万元)',
                        valign: "middle",
                        rowspan: 1,
                        colspan: 4
                    },
                    {
                        align: 'center',
                        title: '四季度(万元)',
                        valign: "middle",
                        rowspan: 1,
                        colspan: 4
                    },
                    {
                        field: 'nextDetail',
                        align: 'center',
                        title: '次月摸底(万元)',
                        valign: "middle",
                        rowspan: 2,
                    },
                    {
                        align: 'center',
                        title: '全年完成(万元)',
                        valign: "middle",
                        rowspan: 1,
                        colspan: 13

                    },
                ],
                [{
                    field: 'secondDetails',
                    align: 'center',
                    title: '二季度摸底(万元)',
                    valign: "middle",
                },
                    {
                        field: 'aprDetail',
                        align: 'center',
                        title: '四月摸底(万元)',
                        valign: "middle",
                    },
                    {
                        field: 'mayDetail',
                        align: 'center',
                        title: '五月摸底(万元)',
                        valign: "middle",
                    },
                    {
                        field: 'junDetail',
                        align: 'center',
                        title: '六月摸底(万元)',
                        valign: "middle",
                    },
                    {
                        field: 'threeDetails',
                        align: 'center',
                        title: '三季度摸底(万元)',
                        valign: "middle",
                    },
                    {
                        field: 'julDetail',
                        align: 'center',
                        title: '七月摸底(万元)',
                        valign: "middle",
                    },
                    {
                        field: 'augDetail',
                        align: 'center',
                        title: '八月摸底(万元)',
                        valign: "middle",
                    },
                    {
                        field: 'sepDetail',
                        align: 'center',
                        title: '九月摸底(万元)',
                        valign: "middle",
                    },
                    {
                        field: 'fourthDetails',
                        align: 'center',
                        title: '四季度摸底(万元)',
                        valign: "middle",
                    },
                    {
                        field: 'octDetail',
                        align: 'center',
                        title: '十月摸底(万元)',
                        valign: "middle",
                    },
                    {
                        field: 'novDetail',
                        align: 'center',
                        title: '十一月摸底(万元)',
                        valign: "middle",
                    },
                    {
                        field: 'decDetail',
                        align: 'center',
                        title: '十二月摸底(万元)',
                        valign: "middle",
                    },
                    {
                        field: 'accFinish',
                        align: 'center',
                        title: '全年完成(万元)',
                        valign: "middle",
                    },
                    {
                        field: 'janFinish',
                        align: 'center',
                        title: '一月完成(万元)',
                        valign: "middle",
                    },
                    {
                        field: 'febFinish',
                        align: 'center',
                        title: '二月完成(万元)',
                        valign: "middle",
                    },
                    {
                        field: 'marFinish',
                        align: 'center',
                        title: '三月完成(万元)',
                        valign: "middle",
                    },
                    {
                        field: 'aprFinish',
                        align: 'center',
                        title: '四月完成(万元)',
                        valign: "middle",
                    },
                    {
                        field: 'mayFinish',
                        align: 'center',
                        title: '五月完成(万元)',
                        valign: "middle",
                    },
                    {
                        field: 'junFinish',
                        align: 'center',
                        title: '六月完成(万元)',
                        valign: "middle",
                    },
                    {
                        field: 'julFinish',
                        align: 'center',
                        title: '七月完成(万元)',
                        valign: "middle",
                    },
                    {
                        field: 'augFinish',
                        align: 'center',
                        title: '八月完成(万元)',
                        valign: "middle",
                    },
                    {
                        field: 'sepFinish',
                        align: 'center',
                        title: '九月完成(万元)',
                        valign: "middle",
                    },
                    {
                        field: 'octFinish',
                        align: 'center',
                        title: '十月完成(万元)',
                        valign: "middle",
                    },
                    {
                        field: 'novFinish',
                        align: 'center',
                        title: '十一月完成(万元)',
                        valign: "middle",
                    },
                    {
                        field: 'decFinish',
                        align: 'center',
                        title: '十二月完成(万元)',
                        valign: "middle",
                    }],

            ]
        };
        $.table.init(options);
    }

    /* 初始化 树组件 */
    function queryProjectTree() {
        var url = prefix + "/treeData";
        var options = {
            url: url,
            expandLevel: 0,
            onClick: zOnClick
        };

        $.tree.init(options);

        function zOnClick(event, treeId, treeNode) {
            if (treeNode.grade == 1) {
                $(".add").hide();
                $(".search").show();
                $(".export").show();
                $("input[name='companyId']").val(treeNode.id);
                $("input[name='proId']").val('');
                $("input[name='programId']").val('');
                $.table.search("", "bootstrap-price", "")
                $.table.search("", "bootstrap-budget", "")
                $.table.search("", "bootstrap-details", "")

            } else if (treeNode.grade == 2) {
                setTimeout(function () {
                    if ($('#bootstrap-price').bootstrapTable('getData', false).length <= 0) {
                        $(".price").addClass("disabled");
                    } else {
                        $(".price").removeClass("disabled");
                    }
                    if ($('#bootstrap-budget').bootstrapTable('getData', false).length <= 0) {
                        $(".budget").addClass("disabled");
                    } else {
                        $(".budget").removeClass("disabled");
                    }
                    if ($('#bootstrap-details').bootstrapTable('getData', false).length <= 0) {
                        $(".details").addClass("disabled");
                    } else {
                        $(".details").removeClass("disabled");
                    }
                }, 100)

                $(".add").show();
                $(".search").hide();
                $(".export").hide();
                $("input[name='companyId']").val(treeNode.pId);
                $("input[name='proId']").val(treeNode.id);
                $("input[name='programId']").val(treeNode.id);
                $.table.search("", "bootstrap-price", "")
                $.table.search("", "bootstrap-budget", "")
                $.table.search("", "bootstrap-details", "")

            }
        }
    }

    //添加
    function add(companyId, proId, type) {
        var url;
        if (type == "基本产值") {
            url = "/planbudget/addBasic?companyId=" + companyId + "&proId=" + proId;
        }
        if (type == "计划预算") {
            url = "/planbudget/addBudget?companyId=" + companyId + "&proId=" + proId;
        }
        if (type == "季度摸底") {
            url = "/planbudget/addDetails?companyId=" + companyId + "&proId=" + proId;
        }
        $.modal.open("添加" + type, url);
    }

    /*表格刷新*/
    function refresh() {
        setTimeout(function () {
            $("#bootstrap-price").bootstrapTable('refresh');
            $("#bootstrap-budget").bootstrapTable('refresh');
            $("#bootstrap-details").bootstrapTable('refresh');
        }, 200)

    }

    //修改
    function edit(programId, type) {
        var url;
        if (type == "基本产值") {
            url = prefix + '/editBasicView?programId=' + programId;
        }
        if (type == "计划预算") {
            url = prefix + '/editBudgetView?programId=' + programId;
        }
        if (type == "季度摸底") {
            url = prefix + '/editDetailView?programId=' + programId;
        }
        $.modal.open(type + "报表编辑", url);
    }

    //删除
    function remove(type) {
        var url;
        var ids;
        if (type == "基本产值") {
            url = prefix + '/removeBasic';
            ids = $('#bootstrap-price').bootstrapTable('getData', false)[0].basicId;
        }
        if (type == "计划预算") {
            url = prefix + '/removeBudget';
            ids = $('#bootstrap-budget').bootstrapTable('getData', false)[0].planId;
        }
        if (type == "季度摸底") {
            url = prefix + '/removeDetails';
            ids = $('#bootstrap-details').bootstrapTable('getData', false)[0].detailId;
        }
        $.ajax({
            url: url,
            data: {
                ids: ids
            },
            type: 'POST',
            success: function (data) {
                $.modal.msgSuccess('删除成功！');
                refresh();
            }
        })
    }

    //导出
    function exportStatisticExcel(type) {
        var typeFlag;
        var url = prefix + '/export';
        if(type == "基本产值"){
            typeFlag = "0";
        }
        if(type == "计划预算"){
            typeFlag = "1";
        }
        if(type == "季度摸底"){
            typeFlag = "2";
        }
        var data = {
            companyId: $("input[name='companyId']").val(),
            typeFlag:typeFlag,
        }
        $.modal.confirm("确定导出所有" + table.options.modalName + "吗？", function () {
            $.modal.loading("正在导出数据，请稍后...");
            $.post(prefix + "/export", data, function (result) {
                if (result.code == web_status.SUCCESS) {
                    window.location.href = ctx + "common/download?fileName=" + encodeURI(result.msg) + "&delete=" + true;

                } else if (result.code == web_status.WARNING) {
                    $.modal.alertWarning(result.msg)
                } else {
                    $.modal.alertError(result.msg);
                }
                $.modal.closeLoading();
            });
        });
    }


    /* 初始化树组件 > 展开 */
    $('#btnExpand').click(function () {
        $._tree.expandAll(true);
        $(this).hide();
        $('#btnCollapse').show();
    });

    /* 初始化树组件 > 折叠 */
    $('#btnCollapse').click(function () {
        $._tree.expandAll(false);
        $(this).hide();
        $('#btnExpand').show();
    });

    /* 初始化树组件 > 刷新 */
    $('#btnRefresh').click(function () {
        queryProjectTree();
    });


</script>
</body>
</html>